package icu.smile.proxy;
 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
 * 参考地址:https://blog.csdn.net/fangquan1980/article/details/80296002
 * @author edz
 *
 */
public class test {
 
	/**
	 * java执行cmd命令
	 * 可以使用 && 来连接两条命令,示例：  String cmd = “cmd /c D: && cd D:\\img && dir /b”;
	 */
	public static void main(String[] args) {
		/**
		 * 操作过程：切换到待识别图片所在目录c盘的test目录下，执行ocr命令，识别图片内容保存到4.txt文件中
		 */
		// Java调用 dos命令,跳转到c:test目录下，执行 tesseract 1.png 4 -l chi_sim命令
		String cmd = "tesseract https://proxy.mimvp.com/common/ygrandimg?id=6&port=MmjiZmtvapW12cDgw stdout";
		try {
			Process process = Runtime.getRuntime().exec(cmd);
			BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
			String content = br.readLine();
			if (content.length()==3 && content.contains("B")){
			 	content = content.replace("B","");
			}
			System.out.println(content);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}